import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/Home.vue'
import Login from '@/views/Login.vue'
import NoFooterLayout from '@/layouts/NoFooterLayout.vue'

const Collection = () => import('@/views/Collection.vue')
const VisitorServices = () => import('@/views/VisitorServices.vue')
const Exhibitionhall = () => import('@/views/Exhibitionhall.vue')
const Profile =() =>import('@/views/Profile.vue')

Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    redirect:'/home',
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    meta: { title: '首页' }
  },
  {
    path: '/collection',
    name: 'Collection',
    component: Collection,
    meta: { title: '藏品信息' }
  },
  {
    path: '/exhibitionhall',
    name: 'Exhibitionhall',
    component: Exhibitionhall,
    meta: { title: '展览馆信息' },
    children: [
      { path: 'floor-1', component: () => import('@/views/Exhibitionhall.vue') },
      { path: 'floor-2', component: () => import('@/views/Exhibitionhall.vue') },
      { path: 'floor-3', component: () => import('@/views/Exhibitionhall.vue') }
    ]
  },
  {
    path: '/culturalproducts',
    name: 'CulturalProducts',
    component: () => import('@/views/CulturalProducts.vue'),
    meta: {
      title: '文创臻品 -历史博物馆'
    }
  },
  {
    path: '/visitorservices',
    name: 'VisitorServices',
    component: VisitorServices,
    meta: { title: '游客服务' }
  },
  {
    path: '/exhibition',
    component: () => import('@/views/Exhibition.vue'),
    children: [
      {
        path: 'permanent',
        name: 'Permanent',
        component: () => import('@/views/exhibition/Permanent.vue'),
        meta: { 
          title: '常设展览 - 历史博物馆',
          bgColor: 'bg-permanent',
          direction: 'left',
          category:'常设展览',
          english:'传承千年的文明记忆，永不落幕的文化盛宴'
        }
      },
      {
        path: 'temporary',
        name: 'Temporary',
        component: () => import('@/views/exhibition/Temporary.vue'),
        meta: { 
          title: '临时展览 - 历史博物馆',
          bgColor: 'bg-temporary',
          direction: 'right',
          category:'临时展览',
          english:'展现万象的文化画卷，永不褪色的艺术长廊'
        }
      },
      {
        path: 'review',
        name: 'Reviews',
        component: () => import('@/views/exhibition/Review.vue'),
        meta: { 
          title: '展览回顾 - 历史博物馆',
          bgColor: 'bg-review',
          direction: 'left',
          category:'展览回顾',
          english:'凝聚古今的艺术魅力，永不消逝的文化传奇'
        }
      },
      {
        path: '/profile',
        name: 'Profile',
        component: Profile,
        meta: { 
          title: '个人中心 - 历史博物馆',
        }
      },
      {
        path: '/login',
        name: 'Login',
        component: NoFooterLayout,
        children:[
          {
            path:'',
            name:'Login',
            component:Login,
          meta: { 
            title: '登录 - 历史博物馆',
            direction: 'left',
            category:'登录',
            english:'用户登录'
        }
      }
      ]
      }
    ]
  }
]
 
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
})

router.beforeEach((to, from, next) => {
  document.title = to.meta.title || '博物馆管理系统';
  next();
});

export default router;



